package com.sky.financelake.ui.activity;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.lifecycle.ViewModelProvider;

import com.sky.financelake.base.BaseA;
import com.sky.financelake.databinding.ActivityStockDetailBinding;
import com.sky.financelake.viewmodels.remote.StockDetailViewModel;

import dagger.hilt.android.AndroidEntryPoint;

@AndroidEntryPoint
public class StockDetailA extends BaseA {

    private ActivityStockDetailBinding binding;
    private StockDetailViewModel viewModel;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityStockDetailBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        AppCompatTextView tvInfo = binding.tvInfo;

        viewModel = new ViewModelProvider(this).get(StockDetailViewModel.class);
        viewModel.getStockDetailLiveData().observe(this, stockDtoApiResponse -> {
            tvInfo.setText(stockDtoApiResponse.getResult().getName());
        });
        viewModel.getStockByCode("000001");

    }
}
